<template>
  <div class="title-bar">
      <div class="title-bar-left"><div class="title">{{title}}</div></div>
      <div class="title-bar-right">
        <div @click="minimizeWin" class="btn-operate minimum-button">
          <img src="~@/assets/bar/minimum.svg" />
        </div>
        <div @click="closeWin" class="btn-operate close-button">
          <img src="~@/assets/bar/close.svg" />
        </div>
      </div>
  </div>
</template>
<script>
import { ipcApiRoute } from '@/api/main';
import { ipc,isEE } from '@/utils/ipcRenderer';
import { message } from 'ant-design-vue';

export default {
  name: "LoginTitle",
  props: ['title'],
  mounted () {
    this.init();
  },

  methods: {
    init () {
      //初始化过程
    },
    minimizeWin() {
      ipc.invoke(ipcApiRoute.window.minimizeWindow).then((ret) => {
        console.log("minimizeWindow:",ret);
      });
    },
    closeWin() {
      ipc.invoke(ipcApiRoute.window.closeWindow).then((ret) => {
        console.log("closeWindow:", ret);       
      });
    },
    
    sendToMainSign(){
      isEE 
      ?ipc.invoke(ipcApiRoute.getWCid, 'main').then(id => {      
        this.mainWCid = id;
        ipc.sendTo(this.mainWCid, specialIpcRoute.window2ToWindow1, '登录结果返回主窗口！');
       }) :console.log("Not in EE!"); 
    }
  }
}

</script>
<style scoped>
.title-bar {
  width: 100%;
  height: 30px;
  display: flex;
  padding:0;
  user-select: none;
  color:rgb(116, 131, 131);
  background-color:#fefefe;  
}

.title-bar-left,
.title-bar-right {
  height: 30px; 
  float: left;
  display: flex;
  justify-content: center;
  align-items: center;
}
.title-bar-left {   -webkit-app-region: drag; width: 100%;  margin-left:40px; margin-right:40px;}
.title-bar-left img {
  margin-left: 10px;
}

.title-bar-right {
  width: 100px;  
  right: 0rem;
  position: absolute;
  display: flex;
  justify-content: right;
}
.title-bar .title {
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-app-region: drag;
  font-size: 13px;
  text-align: center;
  margin-top: -2px;
}

.title-bar .btn-operate {
  width: 30px;
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  -webkit-app-region: no-drag;
  transition:opacity 0.2s ease;
  margin-top: 0px;
}

.title-bar .btn-operate img {
  width: 14px;
  height: 14px;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.title-bar .btn-operate:hover img {
  opacity: 1;
}

.title-bar .close-button:hover {
    background-color:#b0b0b0;transition: opacity 0.5s ease;
}
.title-bar .minimum-button:hover {
    background-color:#c0c0c0;transition: opacity 0.5s ease;
}
</style>
